import { ISDK } from "../Interface/ISDK";
import SDKADManager from "../SDKADManager";
import { ECheckState } from "../common/ECheckState";
import LTHttp from "../../Net/LTHttp";

export default class SDK_Default implements ISDK {
    payRate: number;
    isShielding: boolean;
    isDelayClose: boolean;
    checkState: ECheckState;
    isADConfigInited: boolean;
    isADEnable: boolean;
    isConfigEnable: boolean;
    flg: string;
    channel: string;
    appId: string;
    controlVersion: string;
    adManager: SDKADManager;
    uid: string = "sdk_test";

    Init(flg: string, channel: string, controlVersion: string, appid: string) {
        this.checkState = ECheckState.Normal;
        this.isADConfigInited = true;
        this.isADEnable = true;
        this.isConfigEnable = true;
        this.flg = flg;
        this.channel = channel;
        this.controlVersion = controlVersion;
        this.appId = appid;

        this.adManager = new SDKADManager();

        this._RequestCheckState();
        console.log("SDK:Init", this);
    }

    // 格式 {"tt4d5w4d8" : {"0510" :{"check_type" : 1} }}
    protected _RequestCheckState() {
        let packConfigUrl = "";
        if (!packConfigUrl) return;
        LTHttp.Send(packConfigUrl, Laya.Handler.create(null, (res) => {
            let parseData = JSON.parse(res);
            let data = parseData["data"];
            if (data) {
                this.checkState = data["is_review"] ? ECheckState.InCheck : ECheckState.Normal;
            }
            console.log("检查状态更新", this.checkState);
        }), Laya.Handler.create(null, (res) => {
            this.checkState = ECheckState.Normal;
            console.log("获取版本状态失败", res);
        }), true);
    }

    Login(code: string, fromAppId: string) {
        console.log("SDK:Login", code, fromAppId);
    }

    RequestRemoteConfig() {
        console.log("SDK:RequestRemoteConfig");
    }

    RequestADList() {
        console.log("SDK:RequestADList");
    }
}